package com.sr.recitewords.common.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 分页类型的响应数据
 */
@ApiModel(value = "PageData", description = "分页类型的响应数据")
public class PageData<T> extends BaseData<List<T>> {

    public PageData() {
    }

    public PageData(int count, int pageCount, List<T> bussData) {
        super(bussData);
        this.count = count;
        this.pageCount = pageCount;
    }

    /**
     * 总数据条数
     */
    @ApiModelProperty(value = "总数据条数")
    private int count = 0;

    /**
     * 总分页数
     */
    @ApiModelProperty(value = "总分页数")
    private int pageCount = 0;

    /**
     * 扩展信息，比如可以存储像合计、统计这一类的数据
     */
    @ApiModelProperty(value = "扩展信息，比如可以存储像合计、统计这一类的数据")
    private Map<String, Object> ext;


    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public Map<String, Object> getExt() {
        return ext;
    }

    public void setExt(Map<String, Object> ext) {
        this.ext = ext;
    }

    @Override
    public String toString() {
        return "PageData{" +
                "count=" + count +
                ", pageCount=" + pageCount +
                ", ext=" + ext +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        PageData<?> pageData = (PageData<?>) o;
        return count == pageData.count &&
                pageCount == pageData.pageCount &&
                Objects.equals(ext, pageData.ext);
    }

    @Override
    public int hashCode() {

        return Objects.hash(super.hashCode(), count, pageCount, ext);
    }
}